package com.hfut.jpoa.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hfut.jpoa.common.dto.ResultDto;
import com.hfut.jpoa.dao.CustomerDAO;
import com.hfut.jpoa.dao.QuoteDAO;
import com.hfut.jpoa.dto.QuoteDTO;
import com.hfut.jpoa.model.Quote;
import com.hfut.jpoa.service.QuoteService;
import com.hfut.jpoa.service.exception.QuoteException;

public class QuoteServiceImpl implements QuoteService
{

	private static final Logger LOGGER = LoggerFactory
	        .getLogger(QuoteServiceImpl.class);

	/**
	 * 调度DAO
	 */
	private QuoteDAO quoteDAO;

	/**
	 * 客户DAO
	 */
	private CustomerDAO customerDAO;

	public ResultDto<Quote> queryInfoForPage(QuoteDTO condition)
	        throws QuoteException
	{
		ResultDto<Quote> findInfoForPage = quoteDAO.findInfoForPage(condition);
		return findInfoForPage;
	}

	public void insert(Quote condition) throws QuoteException
	{
		// TODO Auto-generated method stub

	}

	public void update(Quote record) throws QuoteException
	{
		quoteDAO.updateByPrimaryKey(record);

	}

	public Quote findInfo(Quote condition) throws QuoteException
	{

		return quoteDAO.findInfoForPage(condition);
	}

	public boolean codeValidator(Quote condition) throws QuoteException
	{
		// TODO Auto-generated method stub
		return false;
	}

	public List<Quote> queryList(Quote condition) throws QuoteException
	{
		// TODO Auto-generated method stub
		return null;
	}

	public void setQuoteDAO(QuoteDAO quoteDAO)
	{
		this.quoteDAO = quoteDAO;
	}

	public void save(Quote quote) throws QuoteException
	{
		if (null == quote)
		{
			LOGGER.error("Quote is empty.");
			throw new QuoteException("Quote info is empty");
		}

		// 新增一条客户信息
		quoteDAO.insertSelective(quote);
	}

	public CustomerDAO getCustomerDAO()
	{
		return customerDAO;
	}

	public void setCustomerDAO(CustomerDAO customerDAO)
	{
		this.customerDAO = customerDAO;
	}

}
